chore: unify resilience tests and add 401/mid-execution-maintenance scenarios#6807
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This comment has been minimized.
This comment has been minimized.
| it('does not attempt any retries', async () => { | ||
| await runSnykCLI(`test -d --log-level=trace`, { | ||
| env: { | ||
| ...env, | ||
| // apply a user configured attempts of 10 | ||
| INTERNAL_NETWORK_REQUEST_MAX_ATTEMPTS: '10', | ||
| }, | ||
| }); | ||
|
|
||
| // Count how many times an endpoint was hit | ||
| const requests = server.getRequests(); | ||
| const actualNetworkAttempts = requests.filter( | ||
| (r) => r.url.includes('/test-dep-graph') || r.url.includes('/vuln/'), | ||
| ).length; | ||
|
|
||
| expect(actualNetworkAttempts).toBe(1); | ||
| }); |
There was a problem hiding this comment.
hmm I think this test is missing in the new file?
There was a problem hiding this comment.
I am not fully sure why: the PR description mentions "remove individual test" but the backing ticket does not mention any of that
There was a problem hiding this comment.
could you please clarify what you mean? What is the problem you think needs to be addressed?
| INTERNAL_NETWORK_REQUEST_MAX_ATTEMPTS: '1', | ||
| INTERNAL_NETWORK_REQUEST_RETRY_AFTER_SECONDS: '1', |
There was a problem hiding this comment.
Also these two are not present in the new file
There was a problem hiding this comment.
Yes, this was intentional!
INTERNAL_NETWORK_REQUEST_RETRY_AFTER_SECONDS has no real meaning in the test
and INTERNAL_NETWORK_REQUEST_MAX_ATTEMPTS is replaced by the official env var SNYK_MAX_ATTEMPTS
| envOverrides: { | ||
| SNYK_TIMEOUT_SECS: String(TIMEOUT_SECS), | ||
| }, | ||
| skip: ['container sbom scratch'], |
There was a problem hiding this comment.
hmmm do we want to skip this here?
There was a problem hiding this comment.
We currently skip these tests for all cases that do not yet behave consistent. This decouples solving of the inconsistency from merging the test suite.
| // Should send instrumentation data even on timeout | ||
| const requests = server.getRequests(); | ||
| const instrumentationRequest = requests.find((r) => | ||
| r.url?.includes(`/api/hidden/orgs/${orgId}/analytics`), | ||
| ); | ||
| expect(instrumentationRequest).toBeDefined(); |
There was a problem hiding this comment.
I guess this is also absent in the new file
| beforeEach(async () => { | ||
| initialConfig = await getCliConfig(); | ||
| // Set server to delay responses longer than the timeout (10s > 5s timeout) | ||
| server.setResponseDelay(SERVER_DELAY_MS); | ||
| }); |
There was a problem hiding this comment.
We don't have beforeEach in the new file, is that intentional?
There was a problem hiding this comment.
This is now in the setup function for the scenario.
There was a problem hiding this comment.
| 'monitor', | ||
| 'whoami', | ||
| 'auth 11111111-2222-3333-4444-555555555555', | ||
| 'sbom --org=11111111-1111-1111-1111-111111111111 --format=cyclonedx1.4+json', |
There was a problem hiding this comment.
Before it was:
sbom --org=test-org --format=cyclonedx1.4+json
Any reason for changing the org here?
There was a problem hiding this comment.
I think this is just about aligning the test with baseEnv defined in lines 195-201
There was a problem hiding this comment.
org-id vs org-slugname, internally we use only org-id, if a slugname is specified a lookup needs to happen, which I wanted to avoid in the test.
There was a problem hiding this comment.
Do we have any test that tests this lookup happens / should happen?
There was a problem hiding this comment.
yes, we have tests in gaf that are specifically focussing in this logic (openbox). The test goal here is error behaviour on a closed box level.
07a89e6 to
a61fdab
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
6e8030d to
084be22
Compare
This comment has been minimized.
This comment has been minimized.
084be22 to
8e496d9
Compare
PR Reviewer Guide 🔍
|
Pull Request Submission Checklist
are release-note ready, emphasizing
what was changed, not how.
What does this PR do?
This PR moves existing separate tests into a single test suite for easier overview and maintenance.
Where should the reviewer start?
How should this be manually tested?
What's the product update that needs to be communicated to CLI users?
N/A
Risk assessment (Low | Medium | High)?
Low, changes tests only